package models

import (
	"time"
)

// MaOrder [...]
type MaOrder struct {
	OrderID             string    `gorm:"index:OrderID,type:btree;autoIncrement:true;primaryKey;column:order_id;type:int(10) unsigned;not null" json:"order_id" json_old:"OrderID"`
	MerchantID          string    `gorm:"column:merchant_id;type:varchar(30);not null;comment:商户id" json:"merchant_id"`
	SalesID             string    `gorm:"column:sales_id;type:varchar(50);not null;comment:机器标识ID;index:idx_salesID" json:"sales_id" json_old:"SalesID"`
	AddTime             time.Time `gorm:"column:add_time;type:datetime;not null;autoCreateTime;comment:订单生成时间;index:idx_addTime_outTradeNo,sort:desc,priority:1" json:"-" json_old:"AddTime"`
	AddTimeFormated     string    `gorm:"-" json:"add_time"`
	RobotName           string    `gorm:"index:idx_createdDate_robotName,priority:2;column:robot_name;type:varchar(255);not null;comment:机器名称" json:"robot_name" json_old:"RobotName"`
	OutTradeNo          string    `gorm:"column:out_trade_no;type:varchar(255);not null;default:'';comment:订单号;index:idx_addTime_outTradeNo,sort:desc,priority:2;index:idx_outTradeNo_childOutTradeNo,sort:desc,unique,priority:1" json:"out_trade_no" json_old:"OutTradeNo"`
	ChildOutTradeNo     string    `gorm:"column:child_out_trade_no;type:varchar(255); not null;default:'';comment:子订单号;index:idx_outTradeNo_childOutTradeNo,sort:desc,unique,priority:2;index:idx_childOutTradeNo" json:"child_out_trade_no" json_old:"ChildOutTradeNo"`
	RefundTradeNo       string    `gorm:"column:refund_trade_no;type:varchar(50);default:null;comment:退款交易号;index:idx_refundTradeNo" json:"refund_trade_no" json_old:"ReFunTradeNo"`
	OrderStatus         int       `gorm:"column:order_status;type:tinyint(1);not null;comment:0-未初始化 1-创建成功 2-支付成功 3-未支付 4-出货成功 5-出货失败 6-退款 7-错误" json:"order_status" json_old:"OrderStatus"`
	End                 int       `gorm:"column:end;type:tinyint(1);not null;comment:0-正在进行 1-已结束" json:"end" json_old:"End"`
	PaymentID           int8      `gorm:"column:payment_id;type:tinyint;not null;default:0;comment:1-微信 2-支付宝 3支付宝人脸; 3-刷卡 4-好邻居 5 - 兑换码 6 大兴支付 7 赠送" json:"payment_id" json_old:"PaymentID"`
	Areas1              int       `gorm:"column:areas1;type:bigint;default:null;comment:省级ID" json:"areas1" json_old:"Areas1"`
	Areas2              int       `gorm:"column:areas2;type:bigint;default:null;comment:市ID" json:"areas2" json_old:"Areas2"`
	Areas3              int       `gorm:"column:areas3;type:bigint;default:null;comment:商场ID" json:"areas3" json_old:"Areas3"`
	Areas4              int       `gorm:"column:areas4;type:bigint;default:null;comment:自定义标签ID" json:"areas4" json_old:"Areas4"`
	Areas5              int       `gorm:"column:areas5;type:bigint;default:null;comment:区县ID" json:"areas5" json_old:"Areas5"`
	EndOutTradeNo       string    `gorm:"index:idx_end_out_trade_no;column:end_out_trade_no;type:varchar(50);default:null" json:"end_out_trade_no" json_old:"EndOutTradeNo"`
	CountData           string    `gorm:"column:count_data;type:text;not null" json:"count_data" json_old:"CountData"`
	PaymentAmount       float64   `gorm:"column:payment_amount;type:decimal(10,2);default:0.00;comment:订单金额" json:"payment_amount" json_old:"PaymentAmount"`
	DiscountAmount      float64   `gorm:"column:discount_amount;type:decimal(10,2);default:0.00;comment:订单优惠了的金额" json:"discount_amount" json_old:"DiscountAmount"`
	ActualAmount        float64   `gorm:"column:actual_amount;type:decimal(10,2);default:0.00;comment:实付金额" json:"actual_amount" json_old:"ActualAmount"`
	GoodsID             string    `gorm:"column:goods_id;type:int;size:64;comment:商品id" json:"goods_id"`
	ModifyTime          time.Time `gorm:"column:modify_time;type:datetime;default:null;comment:修改时间" json:"-" json_old:"ModifyTime"`
	ModifyTimeFormated  string    `gorm:"-" json:"modify_time"`
	Remarks             string    `gorm:"column:remarks;type:text;default:null;comment:订单备注" json:"remarks" json_old:"Remarks"`
	ErrorCode           string    `gorm:"column:error_code;type:varchar(255);default:null" json:"error_code" json_old:"ErrorCode"`
	LogMsg              string    `gorm:"column:log_msg;type:varchar(255);default:null" json:"log_msg" json_old:"LogMsg"`
	OrigialOutTradeNo   string    `gorm:"column:origial_out_trade_no;type:varchar(255);default:null" json:"origial_out_trade_no" json_old:"OrigialOutTradeNo"`
	CreatedAt           int64     `json:"created_at" gorm:"column:created_at;autoCreateTime;type:int;size:64;comment:创建时间"`
	UpdatedAt           int64     `json:"updated_at" gorm:"column:updated_at;autoUpdateTime;type:int;size:64;comment:更新时间"`
	DeductionLimit      float64   `gorm:"column:deduction_limit;type:decimal(10,2);unsigned;not null;default:0.00;comment:抵扣上限" json:"deduction_limit" json_old:"DeductionLimit"`
	DeductionAmount     float64   `gorm:"column:deduction_amount;type:decimal(10,2);unsigned;not null;default:0.00;comment:抵扣金额" json:"deduction_amount" json_old:"DeductionAmount"`
	PointsAmount        float64   `gorm:"column:points_amount;type:decimal(10,2);unsigned;not null;default:0.00;comment:额购积分" json:"points_amount" json_old:"PointsAmount"`
	PointsValue         float64   `gorm:"column:points_value;type:decimal(10,2);unsigned;not null;default:0.00;comment:积分价值" json:"points_value" json_old:"PointsValue"`
	CreatedDate         time.Time `gorm:"index:idx_createdDate_robotName,priority:1;column:created_date;type:date;autoCreateTime;comment:日期" json:"created_date" json_old:"CreatedDate"`
	CouponCode          string    `gorm:"column:coupon_code;type:varchar(20);default:null;comment:优惠码号" json:"coupon_code" json_old:"CouponCode"`
	LotteryActivityID   string    `gorm:"column:lottery_activity_id;type:varchar(30);default:null;comment:抽奖活动ID" json:"lottery_activity_id" json_old:"LotteryActivityID"`
	IsVisitLottery      int       `gorm:"column:is_visit_lottery;type:tinyint(1);default:0;comment:是否参与抽奖0未参与1参与" json:"is_visit_lottery" json_old:"IsVisitLottery"`
	OrderSource         int       `gorm:"column:order_source;type:tinyint(1);default:0;comment:订单来源: 0-线下 1-线上" json:"order_source" json_old:"OrderSource"`
	ExpiredAt           int64     `json:"expired_at" gorm:"column:expired_at;type:int;size:64;comment:过期时间"`
	InventoryUnfreezeAt int64     `json:"inventory_unfreeze_at" gorm:"column:inventory_unfreeze_at;type:int;size:64;comment:库存解冻时间"`
}

// TableName get sql table name.获取数据库表名
func (m MaOrder) TableName() string {
	return "ma_order"
}

// 模式自动注册
func init() {
	Models = append(Models, &MaOrder{})
}
